package org.example.Server.Impl;

import lombok.extern.slf4j.Slf4j;
import org.example.Mapper.ReportMapper;
import org.example.Pojo.ClazzOption;
import org.example.Pojo.JobOption;
import org.example.Server.ReportServert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ReportServerImpl implements ReportServert {

    @Autowired
    private ReportMapper reportMapper;

    /*
    * 获取数据院并处理
    * */
    @Override
    public JobOption getEmpData() {
        List<Map<String, Object>> mapList = reportMapper.getJobReport();
        JobOption jobOption = new JobOption();
        List<Object> jobList=mapList.stream().map(data->data.get("pos")).toList();
        List<Object> DataList=mapList.stream().map(data->data.get("total")).toList();

        return new JobOption(jobList,DataList);
    }

    /*
    * 获取性别相关数据并处理
    * */
    @Override
    public List<Map<String, Object>> getEmpGanderData() {

        return reportMapper.getGanderReport();
    }


    /*
     * 班级人数统计
     * */
    @Override
    public ClazzOption getStudentCountReport() {
        log.info("getStudentCountReport");
        List<Map<String, Object>> mapList = reportMapper.getStudentCountReport();
        List<Object> clazzList =mapList.stream().map(data-> data.get("className")).toList();
        List<Object> list =mapList.stream().map(data-> data.get("total")).toList();
        return new ClazzOption(clazzList,list);
    }


    /*
     *班级学历统计
     * */
    @Override
    public List<Map<String, Object>> getStudentDegreeReport() {
        return reportMapper.getStudentDegreeReport();
    }



}
